package com.oepm.biz.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.oepm.biz.MajorProAppBiz;
import com.oepm.dao.entity.MajorProAppPo;
import com.oepm.dao.entity.QueryInfo;
import com.oepm.dao.mapper.MajorProAppMapper;
import com.oepm.vo.DataVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class MajorProAppBizImpl implements MajorProAppBiz {
    @Resource
    MajorProAppMapper majorProAppMapper;
    @Override
    public int uploadApp(MajorProAppPo app) {
        return majorProAppMapper.uploadApp(app);
    }

    @Override
    public MajorProAppPo selectAppByPid(String pid) {
        return majorProAppMapper.selectAppByPid(pid);
    }

    @Override
    public List<MajorProAppPo> selectByTeaId(String id) {
        return majorProAppMapper.selectByTeaId(id);
    }

    @Override
    public DataVo<MajorProAppPo> selectByAcademy(QueryInfo queryInfo, String academy) {
        PageHelper.startPage(queryInfo.getPagenum(),queryInfo.getPagesize());
        List<MajorProAppPo> list = majorProAppMapper.selectByAcademy(academy);
        PageInfo<MajorProAppPo> result = new PageInfo<>(list);
        return new DataVo(result.getTotal(),result.getList());
    }

    @Override
    public DataVo<MajorProAppPo> selectAll(QueryInfo queryInfo) {
        PageHelper.startPage(queryInfo.getPagenum(),queryInfo.getPagesize());
        List<MajorProAppPo> list = majorProAppMapper.selectAll();
        PageInfo<MajorProAppPo> result = new PageInfo<>(list);
        return new DataVo(result.getTotal(),result.getList());
    }

    @Override
    public int updateApp(MajorProAppPo app) {
        return majorProAppMapper.updateApp(app);
    }
}
